<#--
/**
 * Copyright 2012 Claude Houle claude.houle@gmail.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-->
<#macro notification id="" type="INFO" zindex=1000 fadeTimeInMillis=5000 title="" message="" center=true middle=true>
<#setting number_format="#">
<#if type="INFO">
	<#assign notificationType="uic-notif-info"/>
</#if>
<#if type="ERROR">
	<#assign notificationType="uic-notif-error"/>
</#if>
<#if type="TRAY">
	<#assign notificationType="uic-notif-tray"/>
</#if>
<#escape x as x?html>
	$( 'body' ).append("<div id='${id}' class='${notificationType} uic-box-shadow' style='z-index:${zindex};'><div class='uic-notif-title'>${title}</div><div class='uic-notif-msg'>${message}</div></div>");
	$( '#${id}' ).bind('click', function( event ){
		event.stopImmediatePropagation();
		$(this).hide(500, function(){
			$(this).remove();
		});
	});

	<#if center>
        var widgetW = $("#${id}").width();
        var winW = $(window).width();
        $("#${id}").css('left', winW/2-widgetW/2);
    </#if>

    <#if middle>
        var widgetH = $("#${id}").height();
        var winH = $(window).height();
        $("#${id}").css('top', winH/2-widgetH/2);
    </#if>

	$("#${id}").fadeIn(250, function(){
        setTimeout("$('#${id}').click();", ${fadeTimeInMillis});
    });
</#escape>
</#macro>